﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ClassLibrary;

namespace WpfOnlineTesting
{
    /// <summary>
    /// Логика взаимодействия для Page1.xaml
    /// </summary>
    public partial class Page1 : Page
    {
        public Page1()
        {
            InitializeComponent();
        }

        private void buttonLogin_Click(object sender, RoutedEventArgs e)
        {
            if (textBox1.Text == string.Empty || passwordBox1.Password == string.Empty )
            {
                label9.Content = "Необходимо заполнить все поля!";
                label9.Visibility = System.Windows.Visibility.Visible;
                return;
            }
        }

        private void buttonRegister_Click(object sender, RoutedEventArgs e)
        {
            if (textBox2.Text == string.Empty || textBox3.Text == string.Empty || passwordBox2.Password == string.Empty || passwordBox3.Password == string.Empty)
            { // если все поля пустые
                label10.Content = "Необходимо заполнить все поля!";
                label10.Visibility = System.Windows.Visibility.Visible;
                return;
            }
            if (passwordBox2.Password != passwordBox3.Password)
            {
                label10.Content = "Пароли не совпадают";
                label10.Visibility = System.Windows.Visibility.Visible;
                return;
            }
            if (!(textBox3.Text.Contains('@') && textBox3.Text.Contains('.')))
            {
                label10.Content = "Неправильно введен E-mail";
                label10.Visibility = System.Windows.Visibility.Visible;
                return;
            }
            if (passwordBox2.Password.Length <4 )
            {
                label10.Content = "Пароль должен быть длиннее 4х символов";
                label10.Visibility = System.Windows.Visibility.Visible;
                return;
            }

        }
    }
}
